//
//  SupportBankChildController.m
//  WBBaseProject
//
//  Created by xiaozhi on 2018/4/4.
//  Copyright © 2018年 吴斌. All rights reserved.
//

#import "SupportBankChildController.h"
#import "BankTableViewCell.h"

#define VH 40

@interface SupportBankChildController ()

@property(strong,nonatomic)NSMutableArray *dataArr;

//@property(strong,nonatomic) UIView * headView;
@property(strong,nonatomic) UIView * footView;
@end

@implementation SupportBankChildController

- (NSMutableArray *)dataArr
{
    if (!_dataArr) {
        _dataArr = [NSMutableArray array];
    }
    return _dataArr;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    [self.tableView registerNib:[UINib nibWithNibName:@"BankTableViewCell" bundle:nil] forCellReuseIdentifier:@"BankTableViewCell"];
    
    [self initVC];
    
   [self getData];
}
- (void)getData
{
    [XYHttpRequest dataRequestWithSupportBankCardListType:self.type success:^(id responseObj) {
        
        if (Success) {
            self.dataArr = responseObj[@"data"];
            
            [self.tableView reloadData];
        }
    } failure:^(NSError *error) {
        
    }];
}
- (void)initVC
{
    [self addNavBtn];
    
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.tableFooterView = [UIView new];
    self.tableView.backgroundColor = [UIColor colorWithRed:239.0/255.0 green:239.0/255.0 blue:239.0/255.0 alpha:1];
}
- (void)addNavBtn{
    //返回按钮
    UIButton *btn = [Factory backButton:self];
    [btn addTarget:self action:@selector(clickBack:) forControlEvents:UIControlEventTouchUpInside];
    
    //    UIButton *right = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
    //    right.titleLabel.font = WB_FontSize(15);
    //    [right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //    [right setTitle:@"添加" forState:UIControlStateNormal];
    //    [right addTarget:self action:@selector(toAdd) forControlEvents:UIControlEventTouchUpInside];
    //    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:right];
    //    self.navigationItem.rightBarButtonItem = item;
}
- (void)clickBack:(id)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)toAdd
{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.dataArr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    BankTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BankTableViewCell"];
    
    NSDictionary *dic = self.dataArr[indexPath.row];
    
    [cell configData:dic];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *vi = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, VH)];
    vi.backgroundColor = [UIColor colorWithRed:239.0/255.0 green:239.0/255.0 blue:239.0/255.0 alpha:1];
    return vi;
}

@end
